<?php
		session_start();

		include ('sqlconnection.php');	
		$db = new Database();
		$db->connect();
		echo "<ul data-role=\"listview\" data-theme=\"a\">";
		
		$query = "select * from property where state = '".$_POST['state']."' and suburb = '".$_POST['suburb']."'" ;
		$result = mysql_query($query);
		while($rows = mysql_fetch_array($result)){
		
        		echo "<div class=\"ui-li ui-li-divider ui-btn ui-bar-d ui-btn-up-undefined\" data-role=\"list-divider\" role=\"heading\">".$rows["address"];
                $totalStars = 5;
				$totalStars -= $rows["rating"];
				for($i = 0 ; $i < $totalStars ; $i++)
				{
					echo "<img src=\"./images/star.gif\" width=\"20\" height=\"20\" align=\"right\" style=\"padding-right:10px; padding-top:3px;\" />";
				}
				
				for($i = 0 ;$i < $rows["rating"] ;$i++)
				{
					echo "<img src=\"./images/star1.gif\" width=\"20\" height=\"20\" align=\"right\" style=\"padding-top:3px; padding-right:3px;\" />";
				}
                echo "</div>";
				
				echo "<li class=\"ui-li-has-thumb ui-btn ui-btn-icon-right ui-li ui-btn-up-a\" style=\"padding:10px; height:80px;\" role=\"option\" tabindex=\"0\" data-theme=\"a\">
<div class=\"ui-btn-inner\">
<div class=\"ui-btn-text\">";
				
                echo "<a class=\"ui-link-inherit\" href=\"property1.php?pid=".$rows["pro_id"]."\">
                <div id=\"property_list\">";
				
			    $query2 = "select image_url from property_images where p_id =".$rows["pro_id"] ;
				$result2 = mysql_query($query2);
				$rows2 = mysql_fetch_array($result2);
				
                echo "<img class=\"ui-li-thumb\" src=\"./images/".$rows2["image_url"]."\" height=\"150px\" width=\"100px\" />";
                
                echo "<div id=\"rooms\" style=\"margin-top:0px; margin-left:0px; position:absolute;\">".$rows["bedroom"]."
                <img src=\"./images/bedroom.png\" width=\"26\" height=\"14\" />&nbsp;&nbsp;".
				$rows["bedroom"].
                "<img src=\"./images/bathroom.png\" width=\"26\" height=\"26\"/>&nbsp;&nbsp;".
                $rows["toilet"].
                "<img src=\"./images/garage.png\" width=\"26\" height=\"26\" />
                </div>
                <div id=\"num_tenants\">
                <br><br>Number of current tenants:&nbsp;";
				
				$query3 = "select count(pro_id) as c from resident where pro_id =".$rows["pro_id"] ;
				$result3 = mysql_query($query3);
				$rows3 = mysql_fetch_array($result3);
				
				for($j = 0 ; $j < $rows3["c"]; $j++)
				{
                echo "<img src=\"./images/avatar.gif\" width=\"20\" height=\"24\" />&nbsp;";
				}
                echo "</div></div></a></div><span class=\"ui-icon ui-icon-arrow-r\"></span></div></li>";
		}
		
		echo "</ul>";
?>